package myky.com.doctorapp.presenter;

import io.reactivex.disposables.Disposable;
import myky.com.doctorapp.entity.HealthEntity;
import myky.com.doctorapp.base.BasePresenterIm;
import myky.com.doctorapp.base.RxSubscribe;
import myky.com.doctorapp.contract.NewSubFragmentContract;
import myky.com.doctorapp.model.NewSubFragmentModel;

public class NewSubFragmentPresenter extends BasePresenterIm<NewSubFragmentContract.View> implements NewSubFragmentContract.Presenter {

    private NewSubFragmentModel newsubFragmentModel;

    @Override
    public void getHealthList(String tagId, String params) {
        newsubFragmentModel.getHealthList(tagId, params).subscribe(new RxSubscribe<HealthEntity.PayLoadBean>() {
            @Override
            protected void onSuccess(HealthEntity.PayLoadBean bean) {
                mView.showHealthtList(bean.getArticleList());
            }

            @Override
            protected void onFailed(int code, String msg) {
                mView.showDataError("健康资讯获取失败");
            }

            @Override
            public void onSubscribe(Disposable d) {
                addSubscription(d);
            }
        });
    }

    public NewSubFragmentPresenter() {
        newsubFragmentModel = new NewSubFragmentModel();
    }

    @Override
    public void getMoreHealthList(String tagId, String params) {
        newsubFragmentModel.getHealthList(tagId, params).subscribe(new RxSubscribe<HealthEntity.PayLoadBean>() {
            @Override
            protected void onSuccess(HealthEntity.PayLoadBean bean) {
                mView.showMoreHealthtList(bean.getArticleList());
            }

            @Override
            protected void onFailed(int code, String msg) {
                mView.showDataError("健康资讯获取失败");
            }

            @Override
            public void onSubscribe(Disposable d) {
                addSubscription(d);
            }
        });

    }
}
